#ifndef CTESTMODEL_H
#define CTESTMODEL_H
//#include <QModelIndex>
#include "CTest.h"
#include "CFileTest.h"
#include "CPrintSettings.h"


class CTestModel : public QAbstractListModel
{
Q_OBJECT
public:
    CTestModel(QObject *parent = 0);
    CTestModel(QString &path, QObject *parent = 0);
    ~CTestModel();
    void init(CListQuestion *listQuestin);
    bool writeTestList(QString t2pFile);
    CTest& getTest();
    QString getTmpDir();
    //virtual functions from QAbstractListModel
    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
    bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
    int rowCount(const QModelIndex &parent = QModelIndex()) const;
    int columnCount(const QModelIndex &parent = QModelIndex()) const;
    Qt::ItemFlags flags(const QModelIndex &index) const;
    QVariant headerData(int section, Qt::Orientation orientation, int role) const;
    bool removeColumns(int column, int count, const QModelIndex &parent = QModelIndex());
    bool insertRow(int row, const QModelIndex &parent = QModelIndex());
    bool removeRow ( int row, const QModelIndex &parent = QModelIndex());
    CPrintSettings getPrintSettings(){return test->getPrintSettings();}
    void savePrintSettings(CPrintSettings &printSettings);
    QString addImage(QString &path);

public slots:
    void addEmptyAnswer(const int &nQuestion, const int &count);
    //QString str;
private:
    QList< QVector< QString > > testList;
    CTest *test;
    CFileTest fileTest;

private: //methods
    void generateTestList();
    void removeLastAnswer(const int &nQuestion);
    void updateListQuestion(int n);
};

#endif // CTESTMODEL_H
